﻿# coding: UTF-8
# Filename : Mysql.py
# Company : imedia
# Author : rose
import MySQLdb


#获取连接
conn = MySQLdb.Connection('192.168.1.201', 'root', 'mysql', 'imedia', use_unicode=True,charset='utf8')
curs = conn.cursor()
curs.execute("select * from ad_media where media_name like '%手机%'")
results = curs.fetchall()
for obj in results:
    print obj[1]
'''
import urllib

from urllib import unquote
def urldecode(url):
    result={}
    url=url.split("?",1)
    if len(url)==2:
        for i in url[1].split("&"):
            i=i.split("=",1)
            if len(i)==2:
                result[unquote(i[0])]=unquote(i[1])
    return result
aa = urldecode("http://www.linuxforum.net/forum/showflat.php?Board=python&Number=539905")

print aa 

str = '中国'
print urllib.quote(str, "GBK")
print urllib.quote(str, "utf-8")
'''
